package com.yonyou.ucf.mdf.app.isvdxq.utils;


import java.util.HashMap;

public class FilePathValidUtil {
    private static final HashMap<String, String> validMap = new HashMap();

    public FilePathValidUtil() {
    }

    public static String validFilePath(String filepath) {
        StringBuilder stringBuilder = new StringBuilder();

        for(int i = 0; i < filepath.length(); ++i) {
            String temp = (String)validMap.get(String.valueOf(filepath.charAt(i)));
            if (temp != null) {
                stringBuilder.append(temp);
            }
        }

        return stringBuilder.toString().replace("..", "").replace("./", "/").replace("/.", "/");
    }

    static {
        validMap.put("a", "a");
        validMap.put("b", "b");
        validMap.put("c", "c");
        validMap.put("d", "d");
        validMap.put("e", "e");
        validMap.put("f", "f");
        validMap.put("g", "g");
        validMap.put("h", "h");
        validMap.put("i", "i");
        validMap.put("j", "j");
        validMap.put("k", "k");
        validMap.put("l", "l");
        validMap.put("m", "m");
        validMap.put("n", "n");
        validMap.put("o", "o");
        validMap.put("p", "p");
        validMap.put("q", "q");
        validMap.put("r", "r");
        validMap.put("s", "s");
        validMap.put("t", "t");
        validMap.put("u", "u");
        validMap.put("v", "v");
        validMap.put("w", "w");
        validMap.put("x", "x");
        validMap.put("y", "y");
        validMap.put("z", "z");
        validMap.put("A", "A");
        validMap.put("B", "B");
        validMap.put("C", "C");
        validMap.put("D", "D");
        validMap.put("E", "E");
        validMap.put("F", "F");
        validMap.put("G", "G");
        validMap.put("H", "H");
        validMap.put("I", "I");
        validMap.put("J", "J");
        validMap.put("K", "K");
        validMap.put("L", "L");
        validMap.put("M", "M");
        validMap.put("N", "N");
        validMap.put("O", "O");
        validMap.put("P", "P");
        validMap.put("Q", "Q");
        validMap.put("R", "R");
        validMap.put("S", "S");
        validMap.put("T", "T");
        validMap.put("U", "U");
        validMap.put("V", "V");
        validMap.put("W", "W");
        validMap.put("X", "X");
        validMap.put("Y", "Y");
        validMap.put("Z", "Z");
        validMap.put("-", "-");
        validMap.put("_", "_");
        validMap.put("0", "0");
        validMap.put("1", "1");
        validMap.put("2", "2");
        validMap.put("3", "3");
        validMap.put("4", "4");
        validMap.put("5", "5");
        validMap.put("6", "6");
        validMap.put("7", "7");
        validMap.put("8", "8");
        validMap.put("9", "9");
        validMap.put(":", ":");
        validMap.put("/", "/");
        validMap.put("\\", "\\");
        validMap.put(".", ".");
    }
}
